package com.sgb.goods.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.sgb.goods.api.GoodsCallBack;
import com.sgb.goods.api.GoodsNet;
import com.sgb.goods.entity.MemberPriceEntity;
import com.sgb.goods.utils.base.viewmodel.BaseViewModel;
import com.sgb.goods.view.adapter.OperationRecordAdapter;
import com.swgk.core.base.model.entity.BaseEntity;

import org.jetbrains.annotations.NotNull;

import java.util.List;

public class OperationRecordViewModel extends BaseViewModel {

    public OperationRecordAdapter adapter;
    public MutableLiveData<List<MemberPriceEntity.MemberPriceSkuDetail>> detailSku = new MutableLiveData<>();
    public MemberPriceEntity.ItemMemberList mData;
    public MutableLiveData<MemberPriceEntity> detail = new MutableLiveData<>();

    public OperationRecordViewModel() {
        adapter = new OperationRecordAdapter();
    }

    /**
     * 获取sku会员价详情信息
     */
    public void getSkuMemberPriceDetail() {
        showLoading();
        if(null == adapter.childItem) {
            return;
        }

        GoodsNet.getInstance().getMemberPriceApi().getSkuMemberPriceDetail(adapter.childItem.itemMemberNo, adapter.childItem.skuId).enqueue(
                new GoodsCallBack<BaseEntity<List<MemberPriceEntity.MemberPriceSkuDetail>>>() {
            @Override
            public void onSuccess(BaseEntity<List<MemberPriceEntity.MemberPriceSkuDetail>> data) {
                detailSku.postValue(data.getData());
            }
        });
    }
}
